﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using QLTV_BLL;
using QLTV_Public;

namespace QLTV_GiaoDien
{
    public partial class uc_NhatKy : DevExpress.XtraEditors.XtraUserControl
    {
        public uc_NhatKy()
        {
            InitializeComponent();
        }
        NhatKy_BLL nhatky_bll = new NhatKy_BLL();
        private void uc_NhatKy_Load(object sender, EventArgs e)
        {
            gridControl1.DataSource = nhatky_bll.LayDuLieu();
        }

        private void bbi_Xoa_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            NhatKy_Public nk = new NhatKy_Public();
            nk.MaNhatKy = Convert.ToInt32(gridView1.GetRowCellValue(gridView1.FocusedRowHandle,"Mã Nhật Ký").ToString());
            if (XtraMessageBox.Show("Bạn có muốn xóa Mã nhật ký: '" + nk.MaNhatKy + "' này không?", "Thông Báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                nhatky_bll.delete_NhatKy(nk);
                uc_NhatKy_Load(sender, e);
            }
        }

        private void bbi_XoaALl_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (XtraMessageBox.Show("Bạn có muốn xóa tất cả nhật ký sử dụng không?", "Thông Báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                nhatky_bll.Delete_NhatKy_all();
                uc_NhatKy_Load(sender,e);
            }
        }

        private void bbi_In_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gridControl1.ShowPrintPreview();
        }

        private void bbi_Refresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            uc_NhatKy_Load(sender,e);
        }

    }
}
